#include "paramsets.h"
#include "ui_paramsets.h"
#include "QDebug"
#include <QtGui>
using namespace std;

ParamSets::ParamSets(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ParamSets)
{
    ui->setupUi(this);

    start = ui->startButton;

    ui->spinBox_1->setValue(0);
    ui->spinBox_1->setRange(0,16);
    ui->spinBox_2->setRange(100,200000);
    ui->spinBox_2->setValue(4000);
    ui->spinBox_2->setSingleStep(1000);
    ui->spinBox_3->setRange(100,2000);
    ui->spinBox_3->setValue(200);
    ui->spinBox_3->setSingleStep(100);

    connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(saveButton_clicked()));
    connect(ui->pushButton_4,SIGNAL(clicked()),this,SLOT(setCurvePath()));
    connect(ui->startButton,SIGNAL(clicked()), this, SLOT(startButton_clicked()));
//    connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(on_pushButton_2_clicked()));
}

ParamSets::~ParamSets()
{
    delete ui;
}

void ParamSets::saveButton_clicked()
{
    emit savePdf();
}

void ParamSets::on_pushButton_2_clicked()
{
    testBench = new TestBenchWidget;
    testBench->exec();
}

void ParamSets::startButton_clicked()
{
//    ui->startButton->setDisabled(true);
    emit startclicked();
}

int ParamSets::SRound()
{
    int num=ui->spinBox_1->value();
    return num;
}

int ParamSets::curveNum()
{
    int num=ui->spinBox_2->value();
    return num;
}

int ParamSets::increaseNum()
{
    int num=ui->spinBox_3->value();
    return num;
}


QString ParamSets::getCurvePath()
{
    QString fileName=a;
    return fileName;
}

//void ParamSets::setCurvePath()
//{
//    QString fileName=QFileDialog::getExistingDirectory(this, tr("Open Directory"),
//                                                       ".",
//                                                       QFileDialog::ShowDirsOnly
//                                                       | QFileDialog::DontResolveSymlinks);
////    QString fileName=QFileDialog::getExistingDirectory(this,"Open Directory "
////                                                       "Choose a directory",".",QFileDialog::ShowDirsOnly);

////    QString fileName=QFileDialog::getSaveFileName(this,tr("Choose Curve File"),".",tr("All Files (*.csv)(*)"));

//    ui->lineEdit_2->setText(fileName);
//}


void ParamSets::setCurvePath()
{

//    QString fileName=QFileDialog::getOpenFileName(this,tr("Choose File"),".",tr("All Files (*.out)"));
//    ui->lineEdit_2->setText(fileName);
    QStringList fileNames = QFileDialog::getOpenFileNames(this,tr("Choose File"),".",tr("*.out(*.out)"));
    QString temp = tr("\"")+fileNames.at(0)+tr("\"");
    for(int i=1;i<fileNames.size();i++)
    {
        a = fileNames.at(i);
        temp += tr("\"")+fileNames.at(i)+tr("\"");



    }
    ui->lineEdit_2->setText(temp);
}

